package com.tc.service;

import com.tc.pojo.Customer;
import com.tc.repositories.CustomerRepository;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

/***
 * @Author 徐庶   QQ:1092002729
 * @Slogan 致敬大师，致敬未来的你
 */
@Service
@Slf4j
public class CustomerServiceImple implements  CustomerService{

    @Autowired
    CustomerRepository repository;

    @Override
    @Transactional(readOnly = true)
    public Iterable<Customer> getAll() {
        try {
            Thread.sleep(1000000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        final Iterable<Customer> all = repository.findAll();

        return all;
    }
    @Override
    @Transactional
    public Iterable<Customer> getAll2() {
        log.info("start.................");
        final Iterable<Customer> all = repository.findAll();
        log.info("end.................: {}", all);
        return all;
    }
}
